package by.bsu.diploma.common;

/**
 * @author Anatoly Selitsky
 */
public class Grid {

    private int[][] cells;
    private int rowCount;
    private int columnCount;

    public Grid(int rowCount, int columnCount) {
        this.rowCount = rowCount;
        this.columnCount = columnCount;
        this.cells = new int[rowCount][columnCount];
    }

    public Grid(int[][] cells) {
        this.cells = cells;
    }

    public int[][] getCells() {
        return cells;
    }

    public int getRowCount() {
        return rowCount;
    }

    public int getColumnCount() {
        return columnCount;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        for(int i = 0; i < rowCount; i++) {
            for(int j = 0; j < columnCount; j++) {
                builder.append(cells[i][j]);
                if (j != columnCount - 1) {
                    builder.append(" ");
                } else {
                    builder.append("\n");
                }
            }
        }
        return builder.toString();
    }

}
